class TechnicalFailuresController < ApplicationController
  # GET /technical_failures
  # GET /technical_failures.xml
  def index
    @technical_failures = TechnicalFailure.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @technical_failures }
    end
  end

  # GET /technical_failures/1
  # GET /technical_failures/1.xml
  def show
    @technical_failure = TechnicalFailure.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @technical_failure }
    end
  end

  # GET /technical_failures/new
  # GET /technical_failures/new.xml
  def new
    @technical_failure = TechnicalFailure.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @technical_failure }
    end
  end

  # GET /technical_failures/1/edit
  def edit
    @technical_failure = TechnicalFailure.find(params[:id])
  end

  # POST /technical_failures
  # POST /technical_failures.xml
  def create
    @technical_failure = TechnicalFailure.new(params[:technical_failure])
		@technical_failure.criticidad = params[:criticidad]
		@technical_failure.bus_id = params[:codigoBus]

		if @technical_failure.save
			respond_to do |format|
        format.html { redirect_to(edit_fleet_path(@technical_failure.bus.fleet), :notice => 'Technical failure was successfully created.') }
        format.xml  { render :xml => @technical_failure, :status => :created, :location => @technical_failure }
			end
		else
			respond_to do |format|
        format.html { render :action => "new" }
        format.xml  { render :xml => @technical_failure.errors, :status => :unprocessable_entity }
		  end
		end
  end

  # PUT /technical_failures/1
  # PUT /technical_failures/1.xml
  def update
    @technical_failure = TechnicalFailure.find(params[:id])

    respond_to do |format|
      if @technical_failure.update_attributes(params[:technical_failure])
        format.html { redirect_to(@technical_failure, :notice => 'Technical failure was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @technical_failure.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /technical_failures/1
  # DELETE /technical_failures/1.xml
  def destroy
    @technical_failure = TechnicalFailure.find(params[:id])
    @technical_failure.destroy

    respond_to do |format|
      format.html { redirect_to(technical_failures_url) }
      format.xml  { head :ok }
    end
  end
end
